<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
    xmlns:s="http://jboss.com/products/seam/taglib"
    xmlns:ui="http://java.sun.com/jsf/facelets"
    xmlns:f="http://java.sun.com/jsf/core"
    xmlns:h="http://java.sun.com/jsf/html"
    xmlns:a="http://richfaces.org/a4j"
    xmlns:rich="http://richfaces.org/rich"
    template="layout/template.xhtml">

<ui:define name="body">

    <h:form id="comment" styleClass="edit">

        <rich:panel>
            <f:facet name="header">#{commentHome.managed ? 'Edit' : 'Add'} Comment</f:facet>



            <s:decorate id="addedField" template="layout/edit.xhtml">
                <ui:define name="label">Added</ui:define>
                <rich:calendar id="added"
                       required="true"
                          value="#{commentHome.instance.added}" datePattern="MM/dd/yyyy hh:mm a"/>
            </s:decorate>




            <s:decorate id="contentField" template="layout/edit.xhtml">
                <ui:define name="label">Content</ui:define>
                <h:inputTextarea id="content"
                               cols="80"
                               rows="10"
                           required="true"
                              value="#{commentHome.instance.content}"/>
            </s:decorate>


            <div style="clear:both">
                <span class="required">*</span>
                required fields
            </div>

        </rich:panel>

        <div class="actionButtons">

            <h:commandButton id="save"
                          value="Save"
                         action="#{commentHome.persist}"
                       disabled="#{!commentHome.wired}"
                       rendered="#{!commentHome.managed}"/>

            <h:commandButton id="update"
                          value="Save"
                         action="#{commentHome.update}"
                       rendered="#{commentHome.managed}"/>

            <h:commandButton id="delete"
                          value="Delete"
                         action="#{commentHome.remove}"
                      immediate="true"
                       rendered="#{commentHome.managed}"/>

            <s:button id="cancelEdit"
                   value="Cancel"
             propagation="end"
                    view="/Comment.xhtml"
                rendered="#{commentHome.managed}"/>

            <s:button id="cancelAdd"
                   value="Cancel"
             propagation="end"
                    view="/#{empty commentFrom ? 'CommentList' : commentFrom}.xhtml"
                rendered="#{!commentHome.managed}"/>

        </div>
    </h:form>

<rich:tabPanel switchType="ajax">

    <rich:tab label="Answer to">
    <div class="association" id="answerToParent">

        <h:outputText value="There is no answerTo associated with this comment."
                   rendered="#{commentHome.instance.answerTo == null}"/>

        <rich:dataTable var="_comment"
                   value="#{commentHome.instance.answerTo}"
                rendered="#{commentHome.instance.answerTo != null}"
              rowClasses="rvgRowOne,rvgRowTwo"
                      id="answerToTable">
            <h:column>
                <f:facet name="header">Id</f:facet>
                <h:outputText value="#{_comment.id}"/>
            </h:column>
            <h:column>
                <f:facet name="header">Added</f:facet>
                <h:outputText value="#{_comment.added}">
                    <s:convertDateTime type="both" dateStyle="short"/>
                </h:outputText>
            </h:column>
            <h:column>
                <f:facet name="header">Answer to id</f:facet>
                <h:outputText value="#{_comment.answerTo.id}"/>
            </h:column>
            <h:column>
                <f:facet name="header">Author id</f:facet>
                <h:outputText value="#{_comment.author.id}"/>
            </h:column>
            <h:column>
                <f:facet name="header">Content</f:facet>
                <h:outputText value="#{_comment.content}"/>
            </h:column>
            <h:column>
                <f:facet name="header">Photo id</f:facet>
                <h:outputText value="#{_comment.photo.id}"/>
            </h:column>
        </rich:dataTable>

    </div>
    </rich:tab>

    <rich:tab label="Author *" labelClass="required">
    <div class="association" id="authorParent">

        <h:outputText value="There is no author associated with this comment."
                   rendered="#{commentHome.instance.author == null}"/>

        <rich:dataTable var="_user"
                   value="#{commentHome.instance.author}"
                rendered="#{commentHome.instance.author != null}"
              rowClasses="rvgRowOne,rvgRowTwo"
                      id="authorTable">
            <h:column>
                <f:facet name="header">Id</f:facet>
                <h:outputText value="#{_user.id}"/>
            </h:column>
            <h:column>
                <f:facet name="header">Dsc</f:facet>
                <h:outputText value="#{_user.dsc}"/>
            </h:column>
            <h:column>
                <f:facet name="header">Email</f:facet>
                <h:outputText value="#{_user.email}"/>
            </h:column>
            <h:column>
                <f:facet name="header">Firstname</f:facet>
                <h:outputText value="#{_user.firstname}"/>
            </h:column>
            <h:column>
                <f:facet name="header">Lastloggedin</f:facet>
                <h:outputText value="#{_user.lastloggedin}">
                    <s:convertDateTime type="both" dateStyle="short"/>
                </h:outputText>
            </h:column>
            <h:column>
                <f:facet name="header">Lastname</f:facet>
                <h:outputText value="#{_user.lastname}"/>
            </h:column>
            <h:column>
                <f:facet name="header">Password</f:facet>
                <h:outputText value="#{_user.password}"/>
            </h:column>
            <h:column>
                <f:facet name="header">Registered</f:facet>
                <h:outputText value="#{_user.registered}">
                    <s:convertDateTime type="both" dateStyle="short"/>
                </h:outputText>
            </h:column>
            <h:column>
                <f:facet name="header">Role id</f:facet>
                <h:outputText value="#{_user.role.id}"/>
            </h:column>
            <h:column>
                <f:facet name="header">Status id</f:facet>
                <h:outputText value="#{_user.status.id}"/>
            </h:column>
            <h:column>
                <f:facet name="header">Username</f:facet>
                <h:outputText value="#{_user.username}"/>
            </h:column>
        </rich:dataTable>

        <div class="actionButtons">
            <s:button id="#{commentHome.instance.author != null ? 'changeParent' : 'selectParent'}" value="#{commentHome.instance.author != null ? 'Change' : 'Select'} author"
                       view="/UserList.xhtml">
                <f:param name="from" value="CommentEdit"/>
            </s:button>
        </div>

    </div>
    </rich:tab>

    <rich:tab label="Photo *" labelClass="required">
    <div class="association" id="photoParent">

        <h:outputText value="There is no photo associated with this comment."
                   rendered="#{commentHome.instance.photo == null}"/>

        <rich:dataTable var="_photo"
                   value="#{commentHome.instance.photo}"
                rendered="#{commentHome.instance.photo != null}"
              rowClasses="rvgRowOne,rvgRowTwo"
                      id="photoTable">
            <h:column>
                <f:facet name="header">Id</f:facet>
                <h:outputText value="#{_photo.id}"/>
            </h:column>
            <h:column>
                <f:facet name="header">Added</f:facet>
                <h:outputText value="#{_photo.added}">
                    <s:convertDateTime type="both" dateStyle="short"/>
                </h:outputText>
            </h:column>
            <h:column>
                <f:facet name="header">Album id</f:facet>
                <h:outputText value="#{_photo.album.id}"/>
            </h:column>
            <h:column>
                <f:facet name="header">Camera brand</f:facet>
                <h:outputText value="#{_photo.cameraBrand}"/>
            </h:column>
            <h:column>
                <f:facet name="header">Camera model</f:facet>
                <h:outputText value="#{_photo.cameraModel}"/>
            </h:column>
            <h:column>
                <f:facet name="header">Date taken</f:facet>
                <h:outputText value="#{_photo.dateTaken}">
                    <s:convertDateTime type="both" dateStyle="short"/>
                </h:outputText>
            </h:column>
            <h:column>
                <f:facet name="header">Dsc</f:facet>
                <h:outputText value="#{_photo.dsc}"/>
            </h:column>
            <h:column>
                <f:facet name="header">Filesize</f:facet>
                <h:outputText value="#{_photo.filesize}"/>
            </h:column>
            <h:column>
                <f:facet name="header">Link</f:facet>
                <h:outputText value="#{_photo.link}"/>
            </h:column>
            <h:column>
                <f:facet name="header">Originalheight</f:facet>
                <h:outputText value="#{_photo.originalheight}"/>
            </h:column>
            <h:column>
                <f:facet name="header">Originalwidth</f:facet>
                <h:outputText value="#{_photo.originalwidth}"/>
            </h:column>
            <h:column>
                <f:facet name="header">Owner id</f:facet>
                <h:outputText value="#{_photo.owner.id}"/>
            </h:column>
            <h:column>
                <f:facet name="header">Status id</f:facet>
                <h:outputText value="#{_photo.status.id}"/>
            </h:column>
            <h:column>
                <f:facet name="header">Title</f:facet>
                <h:outputText value="#{_photo.title}"/>
            </h:column>
            <h:column>
                <f:facet name="header">Type</f:facet>
                <h:outputText value="#{_photo.type}"/>
            </h:column>
            <h:column>
                <f:facet name="header">Viewed</f:facet>
                <h:outputText value="#{_photo.viewed}"/>
            </h:column>
        </rich:dataTable>

        <div class="actionButtons">
            <s:button id="#{commentHome.instance.photo != null ? 'changeParent' : 'selectParent'}" value="#{commentHome.instance.photo != null ? 'Change' : 'Select'} photo"
                       view="/PhotoList.xhtml">
                <f:param name="from" value="CommentEdit"/>
            </s:button>
        </div>

    </div>
    </rich:tab>
</rich:tabPanel>
</ui:define>

</ui:composition>
